package com.team.frame.utils.mail;

import java.io.*;

/**
 * Created by Administrator on 2017/2/10.
 */
public class ReadHTML
{
    /**
     * 读取html转换成string类型
     * @param path 路径
     * @return
     */
    public static String readMailToString(String path){
        StringBuffer buff=new StringBuffer();
        InputStreamReader in=null;
        BufferedReader br=null;
        //String path = System.getProperty("user.dir") + "/src/html/mail.html";
        String path1 = "H:\\框架\\Frame.JAVA\\src\\html\\mail.html";
        File file=new File(path1);
        try {
            //解决中文乱码
            in=new InputStreamReader(new FileInputStream(file), "utf-8");
            br=new BufferedReader(in);
            String line=null;
            while((line=br.readLine()) != null){
                //System.out.println(line);
                buff.append(line);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(in!=null){
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(br!=null){
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return buff.toString();
    }

}
